package com.twu.biblioteca;

/******
 * Created by saylward on 6/03/2014.
 */
public class Movie extends Item
{
    private String year;
    private String director;
    private String rating;

    public Movie(String name, String year, String director, String rating)
    {
        super(name);
        this.year = year;
        this.director = director;
        setRating(rating);
        isCheckedOut = false;
        checkedOutBy = "";
    }

    private void setRating(String rating)
    {
        int tryRating;
        try
        {
            tryRating = Integer.parseInt(rating);
            if (tryRating < 11 && tryRating >= 0)
                this.rating = String.valueOf(tryRating);
            else
                this.rating = "Unrated";
        }
        catch (Exception e)
        {
            this.rating = "Unrated";
        }
    }

    public String getYear()
    {
        return year;
    }

    public String getDirector()
    {
        return director;
    }

    public String getRating()
    {
        return rating;
    }
}
